# coding=utf-8
from urllib.parse import urlparse, urlencode, parse_qsl, urlunparse


def oss_style(url, style_name):
    params = {'x-oss-process':style_name}
    url_parts = list(urlparse(url))
    query = dict(parse_qsl(url_parts[4]))
    query.update(params)

    url_parts[4] = urlencode(query)
    return urlunparse(url_parts)


def thumb_oss_style(url):
    return oss_style(url, 'thumb')
